package cn.zj.smart.gencode.beans;

import java.lang.reflect.AnnotatedType;

/**
 * 属性定义
 * @author xi.yang
 * @create 2019-12-19 14:52
 **/
public class PropDef {
    /**
     * 属性类型
     */
    private Class fieldType;
    /**
     * 属性名
     */
    private String fieldName;
    /**
     * 注释
     */
    private String javaDoc;
    /**
     * 默认值
     */
    private String defValue;
    /**
     * 属性的注解
     */
    private AnnotatedType[] annotatedTypes;
    /**
     * 是否是数组
     */
    private boolean array;

    public boolean isArray() {
        return array;
    }

    public void setArray(boolean array) {
        this.array = array;
    }

    public String getFieldName() {
        return fieldName;
    }

    public void setFieldName(String fieldName) {
        this.fieldName = fieldName;
    }

    public String getJavaDoc() {
        return javaDoc;
    }

    public void setJavaDoc(String javaDoc) {
        this.javaDoc = javaDoc;
    }

    public String getDefValue() {
        return defValue;
    }

    public void setDefValue(String defValue) {
        this.defValue = defValue;
    }

    public AnnotatedType[] getAnnotatedTypes() {
        return annotatedTypes;
    }

    public Class getFieldType() {
        return fieldType;
    }

    public void setFieldType(Class fieldType) {
        this.fieldType = fieldType;
    }

    public void setAnnotatedTypes(AnnotatedType[] annotatedTypes) {
        this.annotatedTypes = annotatedTypes;
    }

    public static PropDefBuilder builder() {
        return new PropDefBuilder();
    }

    public static final class PropDefBuilder {
        private Class fieldType;
        private String fieldName;
        private String javaDoc;
        private String defValue;
        private AnnotatedType[] annotatedTypes;
        private boolean array;

        private PropDefBuilder() {
        }

        public PropDefBuilder fieldType(Class fieldType) {
            this.fieldType = fieldType;
            return this;
        }

        public PropDefBuilder fieldName(String fieldName) {
            this.fieldName = fieldName;
            return this;
        }

        public PropDefBuilder javaDoc(String javaDoc) {
            this.javaDoc = javaDoc;
            return this;
        }

        public PropDefBuilder defValue(String defValue) {
            this.defValue = defValue;
            return this;
        }

        public PropDefBuilder annotatedTypes(AnnotatedType[] annotatedTypes) {
            this.annotatedTypes = annotatedTypes;
            return this;
        }

        public PropDefBuilder array(boolean array) {
            this.array = array;
            return this;
        }

        public PropDef build() {
            PropDef propDef = new PropDef();
            propDef.setFieldType(fieldType);
            propDef.setFieldName(fieldName);
            propDef.setJavaDoc(javaDoc);
            propDef.setDefValue(defValue);
            propDef.setAnnotatedTypes(annotatedTypes);
            propDef.setArray(array);
            return propDef;
        }
    }
}
